<?php
namespace Album\Model;

use Zend\InputFilter\Factory as InputFactory;     // <-- Add this import
use Zend\InputFilter\InputFilter;                 // <-- Add this import
use Zend\InputFilter\InputFilterAwareInterface;   // <-- Add this import
use Zend\InputFilter\InputFilterInterface;        // <-- Add this import

class Album implements InputFilterAwareInterface
{
	
 	public $id;
     public $artist;
     public $title;
     protected $inputfilter;

     public function exchangeArray($data)
     {
         $this->id     = (!empty($data['id'])) ? $data['id'] : null;
         $this->artist = (!empty($data['artist'])) ? $data['artist'] : null;
         $this->title  = (!empty($data['title'])) ? $data['title'] : null;
     }
     
     public function getArrayCopy()
     {
     	return get_object_vars($this);
     	
     }
     
     
     public function setInputFilter(InputFilterInterface $inputFilter)
     {
     	throw new \Exception("Not used");
     }
     
     public function getInputFilter()
     {
     	If (!$this->inputfilter)
     	{
     		$inputFilter = new InputFilter();
     		$factory = new InputFactory();
     		
     		$inputFilter->add($factory->createInput(array(
     				'name' => 'id',
     				'required' => false,
     				'filters' => array(
     						array('name' => 'Int'),
     						),
     				)));
     		
     		$inputFilter->add($factory->createInput(array(
     				'name' => 'artist',
     				'required' => true,
     				'filters' => array(
     						array('name' => 'StripTags'),
     						array('name' => 'StringTrim'),
     						),
     				'validators' => array(
     						array(
     								'name' => 'StringLength',
     								'options' => array(
     										'enconding' => 'UTF-8',
     										'min' => 1,
     										'max' => 100,
     										),
     								),
     						),
     				)));
     		
     		$inputFilter->add($factory->createInput(array(
     				'name' => 'title',
     				'required' => true,
     				'filters' => array(
     						array('name' => 'StripTags'),
     						array('name' => 'StringTrim'),
     						),
     				'validators' => array(
     						array(
     								'name' => 'StringLength',
     								'options' => array(
     										'encoding' =>'UTF-8',
     										'min' => 1,
     										'max' => 100,
     										 ),
     								),
     						),
     				)));
     		
     		$this->inputfilter = $inputFilter;
     		
     	     		
     	}
     	return $this->inputfilter;
     }
}